// 训练相关类型定义

export interface AICharacter {
  id: number;
  name: string;
  avatar: string;
  description: string;
  personality: string[];
  specialties: string[];
  difficulty: "beginner" | "intermediate" | "advanced";
  rating: number;
  totalSessions: number;
  isFavorited: boolean;
  tags: string[];
  createdAt: string;
  updatedAt: string;
}

export interface TrainingScenario {
  id: number;
  title: string;
  description: string;
  category: string;
  difficulty: "beginner" | "intermediate" | "advanced";
  estimatedDuration: number; // 分钟
  objectives: string[];
  skills: string[];
  thumbnail: string;
  isPopular: boolean;
  rating: number;
  totalSessions: number;
  isFavorited: boolean;
  tags: string[];
  createdAt: string;
  updatedAt: string;
}

export interface TrainingSession {
  id: string;
  sessionUuid: string;
  userId: number;
  characterId: number;
  scenarioId: number;
  status: "active" | "completed" | "paused" | "cancelled";
  startedAt: string;
  completedAt?: string;
  duration?: number; // 秒
  messageCount: number;
  successAchieved: boolean;
  difficulty: "beginner" | "intermediate" | "advanced";
  settings: {
    language: string;
    voiceEnabled: boolean;
    hints: boolean;
  };
  // Extended fields for session details
  character?: {
    id: number;
    name: string;
    avatar: string;
    personalityType: string;
  };
  scenario?: {
    id: number;
    name: string;
    title?: string;
  };
  overallScore?: number;
  avgResponseTime?: number;
  empathyScore?: number;
  flowScore?: number;
  iceBreakingScore?: number;
  aiFeedback?: string;
  suggestions?: {
    title: string;
    content: string;
  }[];
  createdAt: string;
  updatedAt: string;
}

export interface Message {
  id: string;
  sessionId: number;
  sender: "user" | "ai";
  content: string;
  timestamp: string;
  type: "text" | "image" | "audio" | "system";
  createdAt?: string;
  emotionScore?: number;
  highlightType?: "best" | "error" | "neutral";
  analysis?: string;
  metadata?: {
    emotion?: string;
    confidence?: number;
    suggestions?: string[];
    analysis?: string;
  };
}

export interface TrainingResult {
  sessionId: number;
  success: boolean;
  score: number;
  duration: number;
  messageCount: number;
  skillsImproved: string[];
  areasForImprovement: string[];
  nextRecommendations: string[];
  achievements: string[];
  pointsEarned: number;
}

export interface TrainingReview {
  sessionId: number;
  overallScore: number;
  dimensionScores: {
    communication: number;
    empathy: number;
    problemSolving: number;
    confidence: number;
    adaptability: number;
  };
  keyMoments: {
    timestamp: string;
    messageId: string;
    type: "breakthrough" | "challenge" | "improvement";
    description: string;
  }[];
  improvements: {
    dimension: string;
    before: number;
    after: number;
    change: number;
  }[];
  suggestions: string[];
  nextSteps: string[];
}

export interface CreateSessionData {
  characterId: number;
  scenarioId: number;
  difficulty?: "beginner" | "intermediate" | "advanced";
  settings?: {
    language?: string;
    voiceEnabled?: boolean;
    hints?: boolean;
  };
}

export interface CharacterQueryParams {
  page?: number;
  limit?: number;
  category?: string;
  difficulty?: string;
  search?: string;
  tags?: string[];
  sortBy?: "rating" | "popularity" | "newest";
  sortOrder?: "asc" | "desc";
  userId?: number;
  favorited?: boolean;
}

export interface ScenarioQueryParams {
  page?: number;
  limit?: number;
  category?: string;
  difficulty?: string;
  search?: string;
  tags?: string[];
  sortBy?: "rating" | "popularity" | "newest";
  sortOrder?: "asc" | "desc";
}

// 能力评估相关类型
export interface AssessmentQuestion {
  id: number;
  dimension: string;
  question: string;
  type: "single_choice" | "multiple_choice" | "scale" | "text";
  options?: string[];
  scaleRange?: {
    min: number;
    max: number;
    minLabel: string;
    maxLabel: string;
  };
  required: boolean;
  order: number;
}

export interface AssessmentResult {
  userId: number;
  overallScore: number;
  dimensionScores: {
    communication: number;
    empathy: number;
    problemSolving: number;
    confidence: number;
    adaptability: number;
  };
  strengths: string[];
  weaknesses: string[];
  recommendations: string[];
  completedAt: string;
}

export interface UserAbility {
  userId: number;
  communication: number;
  empathy: number;
  problemSolving: number;
  confidence: number;
  adaptability: number;
  overallScore: number;
  lastUpdated: string;
  assessmentCount: number;
  improvementTrend: {
    dimension: string;
    trend: "up" | "down" | "stable";
    change: number;
  }[];
}

export interface AbilityDimension {
  name: string;
  displayName: string;
  description: string;
  icon: string;
  color: string;
  maxScore: number;
  skills: string[];
  examples: string[];
}

// Daily Challenge types
export interface DailyChallenge {
  id: number;
  title: string;
  description: string;
  category: "training" | "community" | "learning" | "social";
  type?: "training" | "social" | "learning" | "sharing"; // 保持向后兼容
  difficulty: "easy" | "medium" | "hard";
  points: number;
  time_limit?: number; // 时间限制（秒）
  is_completed: boolean;
  isCompleted?: boolean; // 保持向后兼容
  is_claimed: boolean;
  progress?: {
    current: number;
    target: number;
  };
  requirements?: string[];
  icon?: string;
  expires_at?: string;
  completedAt?: string; // 保持向后兼容
  created_at: string;
  createdAt?: string; // 保持向后兼容
  updated_at?: string;
  joining?: boolean; // 用于UI状态
}

// Social Energy Content types
export interface SocialEnergyContent {
  id: number;
  title: string;
  content: string;
  type: string;
  likesCount: number;
  createdAt: string;
}
